<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.js"></script>
</head>
<body>
    <input type="text" id="input" />

    <script>
/* 
        let input = document.getElementById('input')

        let time;

        input.onkeyup = function(e){
            //自己写的防抖函数
            if(time){
                clearTimeout(time);
            }

            time = setTimeout(() => {
                console.log("发送请求",e.target.value);
            }, 500);
        
        }
 */

        let input = document.getElementById('input')

        input.onkeyup =  _.debounce(()=>{
                console.log("发送请求");
        },500);
        


    </script>
</body>
</html>